package com.etone.smartAudit.controller;

import com.etone.smartAudit.service.IapDataMetaService;
import com.etone.smartAudit.service.IapDataModelDictService;
import com.etone.smartAudit.vo.PagerVO;
import com.etone.smartAudit.vo.iapDataMeta.IapDataMetaVO;
import com.etone.smartAudit.vo.iapDataModel.IapDateModelDictVO;
import com.etone.smartAudit.vo.iapDataModel.IapDateModelTagVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: sovy
 * @date: 2020/8/28
 * @description:
 */
@RestController
@AllArgsConstructor
@Api(tags = "元数据-数据字典", value = "IapDataMetaController")
public class IapDataMetaController {

    private IapDataMetaService iapDataMetaService;

    private IapDataModelDictService iapDataModelDictService;

    @GetMapping("/iapDataMetas")
    @ApiOperation(value = "数据字典列表")
    public PagerVO<IapDataMetaVO> list(
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize,
            @ApiParam(value = "元数据id", required = true) @RequestParam Integer iapDataMetaId,
            @ApiParam(value = "关键字(字段名称，说明)") @RequestParam(required = false) String keys
    ) {
        return iapDataMetaService.list(iapDataMetaId, keys, page, pageSize);
    }

    @GetMapping("/iapDataModelDict")
    @ApiOperation(value = "数据标签字典")
    public List<IapDateModelDictVO> tagList(
            @ApiParam(value = "标签类型(0:数据存放平台,1:敏感性,2:数据维护类型,3:数据质量纬度," +
                    "4:使用方纬度,5:自动化纬度)") @RequestParam(required = false) Integer typeId
    ) {
        return iapDataModelDictService.list(typeId);
    }

    @GetMapping("/iapDataModelDictList")
    @ApiOperation(value = "数据标签字典集合")
    public List<IapDateModelTagVO> dictList() {
        return iapDataModelDictService.dictList();
    }
}
